<!-- 我的弹窗 -->

<template>
  <WebModal small>
    <WebForm>
      <FormInput label="模板名称" bind="templateName" :max="6" required />

      <FormPhoto label="图标" bind="icon" folder="repair" text="上传图标" square required />

      <EasyRow col2>
        <FormSelect v-bind="typeProps" />
        <FormSelect v-bind="subTypeProps" word2 />
      </EasyRow>

      <FormTextarea label="工单描述" bind="remark" :max="500" required />
    </WebForm>
  </WebModal>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MyModal',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb()],

  /**
   * 组件导入 (Abc.vue + Abc/index.vue)
   */
  ...CORE.components(require.context('./', true, /vue$/)),

  /**
   * 计算属性 (慎用箭头函数)
   */
  computed: {
    /**
     * 类型属性
     */
    typeProps() {
      return {
        label: '工单类型',
        bind: 'orderTypeId, orderTypeName, orderTypeCode',
        dict: CORE.DICT.task_type,
        required: true,
      }
    },

    /**
     * 子类型属性
     */
    subTypeProps() {
      const { orderTypeCode } = this.one
      return {
        label: '子类',
        bind: 'orderSubTypeId, orderSubTypeName, orderSubTypeCode',
        dict: orderTypeCode ? CORE.DICT.task_sub_type.filter((item) => item[2].includes(orderTypeCode)) : [],
        required: true,
      }
    },
  },
}
</script>
